package cn.wangyaying.salor;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;

import cn.wangyaying.util.Constant;
import cn.wangyaying.util.MyFrame;
import cn.wangyaying.util.Picture;

/**
 *  * 太阳系的主窗口  *   * @author wangyaying  *   
 */

public class SolarFrame extends MyFrame {

	Image img = Picture.getImage("imager/bg.jpg");
	Star sun = new Star("imager/sun.jpg", Constant.GAME_HIGH / 2, Constant.GAME_WIDTH / 2);

	Planet mercury = new Planet(sun, "imager/Mercury.jpg", 50, 30, 0.6);// 水星
	Planet venus = new Planet(sun, "imager/Venus.jpg", 80, 50, 0.4); // 金星
	Planet earth = new Planet(sun, "imager/Earth.jpg", 120, 75, 0.25); // 地球
	Planet mars = new Planet(sun, "imager/Mars.jpg", 170, 120, 0.18); // 火星
	Planet jupiter = new Planet(sun, "imager/Jupiter.jpg", 210, 150, 0.15); // 木星
	Planet saturn = new Planet(sun, "imager/Saturn.jpg", 240, 180, 0.1);// 土星
	Planet uranus = new Planet(sun, "imager/Uranus.jpg", 320, 220, 0.07); // 天王星
	Planet neptune = new Planet(sun, "imager/Neptune.jpg", 370, 280, 0.04); // 海王星

	public void paint(Graphics g) {
		if (img == null) {  
        	img = this.createImage(Constant.GAME_HIGH, Constant.GAME_WIDTH);  
        }
		g.drawImage(img, 0, 0, null);
		sun.draw(g);
		mercury.draw(g);
		venus.draw(g);
		earth.draw(g);
		mars.draw(g);
		jupiter.draw(g);
		saturn.draw(g);
		uranus.draw(g);
		neptune.draw(g);

	}
	 // 重写update方法,先将窗体上的图形画在图片对象上，再一次性显示  
	
   /* public void paint(Graphics g) {  
        if (img == null) {  
        	img = this.createImage(Constant.GAME_HIGH, Constant.GAME_WIDTH);  
        }  
        Graphics gImage = img.getGraphics();  
        Color c = gImage.getColor();  
        gImage.setColor(Color.GREEN);  
        gImage.fillRect(0, 0, Constant.GAME_HIGH, Constant.GAME_WIDTH);  
        gImage.setColor(c);  
        paint(gImage);  
        g.drawImage(img, 0, 0, null);  
        sun.draw(gImage);
		mercury.draw(gImage);
		venus.draw(gImage);
		earth.draw(gImage);
		mars.draw(gImage);
		jupiter.draw(gImage);
		saturn.draw(gImage);
		uranus.draw(gImage);
		neptune.draw(gImage);
    } */

	public static void main(String[] args) {
		new SolarFrame().launchFrame();
	}

}
